﻿' LibWowArmory
' by Ronald M. Clifford (roncli@roncli.com)
'
' This source code is released under the GNU Library General Public License (LGPL) Version 2.1.

Namespace roncliProductions.LibWowArmory.Calendar.Month.World

    ''' <summary>
    ''' A class that defines an event
    ''' </summary>
    ''' <remarks></remarks>
    Public Class CalendarEvent
        Private lngEnd As Long
        Private lngStart As Long
        Private cmwParent As CalendarMonthWorld

        ''' <summary>
        ''' The calendar type of the calendar event
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property CalendarType As String

        ''' <summary>
        ''' The identification number of the calendar type of the calendar event
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property CalendarTypeID As Integer

        ''' <summary>
        ''' A description of the event
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Description As String

        ''' <summary>
        ''' The end date of the event, in UTC
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public ReadOnly Property UTCEnd As Date
            Get
                Return New Date(1970, 1, 1).AddMilliseconds(lngEnd)
            End Get
        End Property

        ''' <summary>
        ''' The icon of the calendar event
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Icon As String

        ''' <summary>
        ''' The priority of the event
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Priority As Integer

        ''' <summary>
        ''' The start date of the event, in UTC
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public ReadOnly Property UTCStart As Date
            Get
                Return New Date(1970, 1, 1).AddMilliseconds(lngStart)
            End Get
        End Property

        ''' <summary>
        ''' The summary of the calendar event
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Summary As String

        ''' <summary>
        ''' The start date of the event, in server time
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public ReadOnly Property [End] As Date
            Get
                If CalendarType = "holidayWeekly" Then
                    Return New Date(1970, 1, 1).AddMilliseconds(lngEnd).Add(cmwParent.TimezoneOffset).AddHours(12)
                Else
                    Return New Date(1970, 1, 1).AddMilliseconds(lngEnd).Add(cmwParent.TimezoneOffset)
                End If
            End Get
        End Property

        ''' <summary>
        ''' The start date of the event, in server time
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public ReadOnly Property Start As Date
            Get
                If CalendarType = "holidayWeekly" Then
                    Return New Date(1970, 1, 1).AddMilliseconds(lngStart).Add(cmwParent.TimezoneOffset).AddHours(12)
                Else
                    Return New Date(1970, 1, 1).AddMilliseconds(lngStart).Add(cmwParent.TimezoneOffset)
                End If
            End Get
        End Property

        ''' <summary>
        ''' A constructor to create a new calendar event
        ''' </summary>
        ''' <param name="strCalendarType"></param>
        ''' <param name="intCalendarTypeID"></param>
        ''' <param name="strDescription"></param>
        ''' <param name="lngEnd"></param>
        ''' <param name="strIcon"></param>
        ''' <param name="intPriority"></param>
        ''' <param name="lngStart"></param>
        ''' <param name="strSummary"></param>
        ''' <param name="cmwParent"></param>
        ''' <remarks></remarks>
        Public Sub New(ByVal strCalendarType As String, ByVal intCalendarTypeID As Integer, ByVal strDescription As String, ByVal lngEnd As Long, ByVal strIcon As String, ByVal intPriority As Integer, ByVal lngStart As Long, ByVal strSummary As String, ByVal cmwParent As CalendarMonthWorld)
            CalendarType = strCalendarType
            CalendarTypeID = intCalendarTypeID
            Description = strDescription
            Me.lngEnd = lngEnd
            Icon = strIcon
            Priority = intPriority
            Me.lngStart = lngStart
            Summary = strSummary
            Me.cmwParent = cmwParent
        End Sub

    End Class

End Namespace